Skip to content

Conversation

@bandures
Copy link

@bandures bandures commented May 23, 2023

Fix CoreCLR debug build randomly failing on initial load.

By default, LoadAssembly loads assemblies up to "FILE_LOADED" state. Whenever we JIT or execute any method through normal means, CoreCLR ensures that required assemblies are activated in advance. However, when we get function pointers through MethodDesc, we avoid all activation points.

#21 0x007f69ef8667e6 in bool ScriptingInvocation::InvokeHandlingReturnValue(ScriptingExceptionPtr*, bool)
#22 0x007f69ef9b49cb in bool ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#23 0x007f69ef745951 in bool ScriptingInvocation::Invoke()
#24 0x007f69ef74549a in Scripting::UnityEngine::ScriptingUtilityProxy::IsManagedCodeWorking(ScriptingExceptionPtr*)
#25 0x007f69ef745f81 in IsManagedCodeWorking()
#26 0x007f69ef743315 in MonoManager::LoadAssemblies(dynamic_bitset)
#27 0x007f69ef742fbe in MonoManager::BeginReloadAssembly(DomainReloadingData&)
#28 0x007f69ef8df65b in MonoManager::ReloadAssembly()
#29 0x007f69ef8df22c in MonoManager::AwakeFromLoad(AwakeFromLoadMode)
#30 0x007f69ef8df151 in AwakeFromLoadQueue::InvokePersistentManagerAwake(AwakeFromLoadQueue::Item*, unsigned int, AwakeFromLoadMode, bool)
#31 0x007f69ef88d746 in AwakeFromLoadQueue::PersistentManagerAwakeFromLoad(int, AwakeFromLoadMode, bool)
#32 0x007f69ef88e772 in AwakeFromLoadQueue::PersistentManagerAwakeFromLoad(ErrorsAndWarningsCapture*, bool)
#33 0x007f69ef88f439 in PersistentManager::IntegrateAllThreadedObjects()
#34 0x007f69ee1d94c0 in PersistentManager::LoadAndIntegrateAllPreallocatedObjects(PersistentManager::LockFlags)
#35 0x007f69edd24601 in PersistentManager::ReadObject(int, AwakeFromLoadMode)
#36 0x007f69edd73d20 in ReadObjectFromPersistentManager(int)
#37 0x007f69ee1e1cd9 in PPtr::operator Object*() const
#38 0x007f69ee1e1e85 in Object* dynamic_instanceID_cast<Object*>(int)
#39 0x007f69eec72e16 in LoadManager(core::basic_string<char, core::StringStorageDefault > const&, int)
#40 0x007f69ef91328b in PlayerLoadGlobalManagers(char const*, char const*, unsigned int)
#41 0x00000000201102 in PlayerInitEngineGraphics(bool)
#42 0x007f69ebf84d90 in PlayerMain(int, char**)`

Assert failure(PID 204152 [0x00031d78], Thread: 204152 [0x31d78]): Consistency check failed: File has not had execution verifiedFAILED: m_bDisableActivationCheck || CheckLoadLevel(FILE_ACTIVE)
FAILED: pDomainAssembly->CheckActivated()
/home/bandures/coreclr/src/coreclr/vm/ceeload.cpp, line: 5043
Managed code can only run when its module has been activated in the current app domain: FAILED: pModule->CheckActivated()
/home/bandures/coreclr/src/coreclr/vm/appdomain.cpp, line: 2537
FAILED: GetAppDomain()->CheckCanExecuteManagedCode(pMD)
/home/bandures/coreclr/src/coreclr/vm/prestub.cpp, line: 1903
File: /home/bandures/coreclr/src/coreclr/vm/domainassembly.cpp Line: 291
Image: /home/bandures/unity/~/player-save/Tests/EditModeAndPlayModeTests/Rendering/Meshes/PlayerWithTests.x86_64

@bandures bandures requested a review from joncham May 23, 2023 18:46
Copy link
Member

@joncham joncham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bandures bandures merged commit a16f72f into unity-main May 23, 2023
@bandures bandures deleted the bugfix/debug-coreclr-fail-assembly-load-check branch May 23, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants